package com.nsn.auction.domina;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name="CATEGORY")
public class Category implements Serializable{
	
	private String name;
	private Long categoryId;
	
	public Category() {}
	
	public Category(String name) {
		this.name = name;
	}
	
	@Column(name="NAME", unique = true, nullable = false, length = 30)
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "CATEGORY_ID", unique = true, nullable = false)
	public Long getCategoryId() {
		return categoryId;
	}
	
	public void setCategoryId(Long categoryId) {
		this.categoryId = categoryId;
	}
	
	@Override
	public boolean equals(Object object) {
		
		//check for selt-comparison
		if (this == object) return true;
		if (!( this.getClass().equals(object.getClass()) )) return false;
		
		Category temp_category = (Category) object;
		 return (null == getName() ? null == temp_category.getName() : getName().equals(temp_category.getName()));
	}

}
